//
//  HWVoiceRoomGiftTopProtocol.swift
//  PlayWithProject
//
//  Created by 王昌健 on 2021/8/27.
//

import UIKit

class HWVoiceRoomGiftTopProtocol: NSObject,UICollectionViewDelegate,UICollectionViewDataSource {
    var seatModels:[HWVoiceRoomSeatModel]?
    var didSelectUser:((_:HWVoiceRoomSeatModel)->())?
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        for mod in seatModels ?? []{
//            mod.selected = !mod.selected
            mod.selected = false
        }
        seatModels?[indexPath.row].selected = true
        didSelectUser?(seatModels![indexPath.row])
    }
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return seatModels?.count ?? 0
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let userCell = collectionView.dequeueReusableCell(withReuseIdentifier: "HWVoiceRoomGiftUserCell", for: indexPath) as! HWVoiceRoomGiftUserCell
        userCell.model = seatModels?[indexPath.row]
        return userCell
        
    }
    

}
